# {{output.header}}
# {{{output.link}}}
{{#if form.hsts}}
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    return 301 https://$host$request_uri;
}

{{/if}}
server {
{{#if (minver "1.9.5" form.serverVersion)}}
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
{{else}}
    listen 443 ssl;
    listen [::]:443 ssl;
{{/if}}

    ssl_certificate /path/to/signed_cert_plus_intermediates;
    ssl_certificate_key /path/to/private_key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
{{#if (minver "1.0.2l" form.opensslVersion)}}
  {{#if (minver "1.5.9" form.serverVersion)}}
    ssl_session_tickets off;
  {{/if}}
{{/if}}

{{#if output.usesDhe}}
    # {{output.dhCommand}} > /path/to/dhparam.pem
    ssl_dhparam /path/to/dhparam.pem;

{{/if}}
    # {{form.config}} configuration
    ssl_protocols{{#each output.protocols}} {{this}}{{/each}};
{{#if output.ciphers.length}}
    ssl_ciphers {{{join output.ciphers ":"}}};
{{/if}}
    ssl_prefer_server_ciphers {{#if output.serverPreferredOrder}}on{{else}}off{{/if}};
{{#if form.hsts}}

    # HSTS (ngx_http_headers_module is required) ({{output.hstsMaxAge}} seconds)
    add_header Strict-Transport-Security "max-age={{output.hstsMaxAge}}"{{#if (minver "1.7.5" form.serverVersion)}} always{{/if}};
{{/if}}
{{#if form.ocsp}}
  {{#if (minver "1.3.7" form.serverVersion)}}

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;

    # verify chain of trust of OCSP response using Root CA and Intermediate certs
    ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

    # replace with the IP address of your resolver
    resolver 127.0.0.1;
  {{/if}}
{{/if}}
}